const currentDate = ()=>{
	const nowDate = new Date();
 const year = nowDate.getFullYear();
 const month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1): nowDate.getMonth() + 1;
 const day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
 const dateStr = year + "-" + month + "-" + day;
 return dateStr
}
const getDate = (date)=>{
	const nowDate = new Date(date);
 const year = nowDate.getFullYear();
 const month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1): nowDate.getMonth() + 1;
 const day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
 const dateStr = year + "-" + month + "-" + day;
 return dateStr
}

const futureDate = (days)=>{
		const date1 = new Date();
        let futureDate = new Date(date1);
        futureDate.setDate(date1.getDate()+days);
        // const time2 = date2.getFullYear()+"-"+(date2.getMonth()+1)+"-"+date2.getDate();
		 const year = futureDate.getFullYear();
		const month = futureDate.getMonth() + 1 < 10 ? "0" + (futureDate.getMonth() + 1): futureDate.getMonth() + 1;
		const day = futureDate.getDate() < 10 ? "0" + futureDate.getDate() : futureDate.getDate();
		const dateStr = year + "-" + month + "-" + day;
		return dateStr
		
}

const pastDate = num=> {
    var date1 = new Date();
    //今天时间
    var time1 = date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate()
    var date2 = new Date(date1);
    date2.setDate(date1.getDate() - num);
    //num是正数表示之后的时间，num负数表示之前的时间，0表示今天
    let nextY = date2.getFullYear()
    let nextM = date2.getMonth() + 1
    let nextD = date2.getDate();
    if (nextM < 10) {
        nextM = "0" + nextM
    }
    if (nextD < 10) {
        nextD = "0" + nextD
    }
    var time2 = nextY + "-" + nextM + "-" + nextD
    return time2;
}

const getWeek = date=>{
	const weekList = new Array("日", "一", "二", "三", "四", "五", "六");
	const week = new Date(date).getDay();
	return weekList[week]
}

export {
	currentDate,
	futureDate,
	pastDate,
	getWeek,
	getDate
}